import http from "@/http/index"
export const userListApi = (params: IUserListParams): RES<IListModel<List>> => http.get('/admin/list', { params })
// 改变用户是否启用
export const switchUserStatusApi = (id: number, status: number): RES<number> => http.post(`/admin/updateStatus/${id}?status=${status}`)
// 添加用户成员
export const addUserApi = (params: List): RES<List> =>
    http.post("/admin/register", params);
// 获取指定的用户信息
export const getUserById = (id: number): RES<List> => http.get(`/admin/${id}`)
// 修改用户成员信息
export const updateUser = (params: List): RES<number> => http.post(`/admin/update/${params.id}`, params)
// 获取所有角色信息
export const getRoleListApi = (): RES<IRoleModel[]> => http.get('/role/listAll')
// 获取指定用户的角色
export const getRolesByUserIdApi = (adminId: number): RES<IRoleModel[]> => http.get(`/admin/role/${adminId}`)
// 
export const updateUserRolesApi = (id: number, ids: number[]): RES<number> => http.post(`/admin/role/update?adminId=${id}&roleIds=${ids.join(',')}`)

// 根据角色名称分页获取角色列表
export const jueSeListApi = (params: IUserListParams): RES<IUserListModel> => http.get('/role/list', { params })
// 添加角色
export const jueSeAddListApi = (params: RootModel): RES<IRootModel> => http.post('/role/create', params)
// 修改角色   /role/update/{id}
export const roleUpdate = (params: RootModel): RES<IRootModel> => http.post(`/role/update/${params.id}`, params)
// 
export const getRourceListByRoleIdApi = (roleId: number): RES<IResourceModel[]> => http.get(`/role/listResource/${roleId}`)
// 
export const resourceListAllApi = (): RES<IResourceModel[]> => http.get('/resource/listAll')
// 
export const resourceCategoryAllApi = (): RES<IResourceCategoryModel[]> => http.get('/resourceCategory/listAll')
export const allocResourceApi = (paramas: allocResourcePramas):RES<number> =>
    http.post(
        `/role/allocResource?roleId=${paramas.roleId
        }&resourceIds=${paramas.resourceIds.join(",")}`
    );

export const treeListApi = (): RES<ItreeMenu[]> => http.get("/menu/treeList");

// 资源列表
export const resourceApi = (params:IListParams):RES<IUserListModel> => http.get("/resource/list",{params})

// 菜单列表
export const menuListByIdApi = (params:IMenuById):RES<IListModel<IMenuModel>> => http.get(`/menu/list/${params.parentId}`,{params})

// 修改菜单显示状态
export const editMenuHiddenApi = (id:number,hidden:number):RES<number> => http.post(`/menu/updateHidden/${id}?hidden=${hidden}`)

// 添加菜单
export const addMenuApi = (params:IMenuModel):RES<number> => http.post("/menu/create",params)

// 根据id获取菜单信息
export const getMenuByIdApi = (id:number):RES<IMenuModel> => http.get(`/menu/${id}`)

// 修改菜单信息
export const updateMenuByIdApi = (params:IMenuModel):RES<number> => http.post(`/menu/update/${params.id}`,params)

// 获取角色相关菜单
export const getRoleMenuByIdApi = (roleId:number):RES<IMenuModel[]> => http.get(`/role/listMenu/${roleId}`)

// 给角色分配菜单
export const allocMenuApi = (paramas:allocMenuParmas):RES<number> => http.post(`/role/allocMenu?roleId=${paramas.roleId}&menuIds=${paramas.menuIds}`)